#! /usr/bin/env bash

# Crop & SlideShow 

lines=$1

width=800
height=$(awk "BEGIN { printf(\"%2.0f\", 16.5 * $lines) }") # 16.5 Pixels / Line

echo "Let's Do This!" | colorize info
mkdir Crop
for shot in ScreenShot*.png; do convert -crop ${width}x${height}\! "$shot" Crop.png; mv Crop-0.png Crop/"$shot" -iv | colorize info; rm Crop*.png; done
pushd Crop
ffmpeg -f image2 -pattern_type glob -i "ScreenShot*.png" -loop 0 -q 1 -s ${width}x${height} SlideShow.gif
mv SlideShow.gif .. -iv | colorize warning
popd
rm -r Crop
#ffmpeg -f image2 -pattern_type glob -i "ScreenShot*.png" -loop 0 -q 1 -vf crop=${width}:${height}:0:0 -s ${width}x${height} SlideShow.gif
echo "Another SlideShow Done!" | colorize info
